from StringIO import StringIO
from Products.CMFCore.utils import getToolByName

def install(self, reinstall=False):
    out = StringIO()
    
    print >> out, "Installing default PFGCaptchaField setup profile"
    setup_tool = getToolByName(self, 'portal_setup')
    try:
        # for Plone 3
        setup_tool.runAllImportStepsFromProfile(
            'profile-Products.PFGCaptchaField:default',
            purge_old=False)
    except AttributeError:
        # for Plone 2.5
        old_context = setup_tool.getImportContextID()
        setup_tool.setImportContext('profile-Products.PFGCaptchaField:default')
        setup_tool.runAllImportSteps()
        setup_tool.setImportContext(old_context)
    print >> out, "Successfully installed PFGCaptchaField."
    return out.getvalue()
